package com.sbtr.controller;


import com.sbtr.business.user.service.IUserService;
import com.sbtr.common.Response;
import com.sbtr.open.user.dto.UserDto;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import java.util.List;

/**
 * <p>
 * 用户信息表，仅记录登录过系统的用户信息 前端控制器
 * </p>
 */
@RestController
@RequestMapping("/user")
@ApiIgnore
public class UserInfoController {


    @Autowired
    private IUserService userService;

    @ApiOperation(value = "新增或修改", notes = "新增或修改新版本", httpMethod = "POST")
    @PostMapping(value = "/save")
    public Response<UserDto> saveCallibration(@RequestBody UserDto dto) {
        return Response.success("保存成功", userService.save(dto));
    }


    @ApiOperation(value = "查询所有用户", notes = "查询所有用户", httpMethod = "GET")
    @GetMapping(value = "/search")
    public Response<List<UserDto>> search() {

        return Response.success(userService.search());
    }

    @ApiOperation(value = "查询单个用户", notes = "查询单个用户", httpMethod = "GET")
    @GetMapping(value = "/search-by-username")
    public Response<List<UserDto>> searchByuserName(@RequestParam("userName") String userName) {

        return Response.success(userService.searchByuserName(userName));
    }



	/*
	@RequestMapping(value = "/search", method = RequestMethod.GET)
	@ApiOperation(value = "分页查询", notes = "分页查询", httpMethod = "GET")
	public Response<PageDto<UserInfoDto>> search(@RequestParam(name = "roleName", required = false) String roleName,
			@RequestParam("page") Long currPage, @RequestParam("pageSize") Long pageSize){
		return Response.success(userInfoApi.search(roleName, currPage, pageSize));
	}
*/


}

